package Finance::NSCC::Insurance::Schema::UnderlyingAsset;

use strict;
use warnings;

use base 'DBIx::Class';

__PACKAGE__->load_components("Core");
__PACKAGE__->table("underlying_assets");
__PACKAGE__->add_columns(
  "nscc_num",
  { data_type => "CHAR", default_value => "", is_nullable => 0, size => 4 },
  "contract_num",
  { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 30 },
  "cusip",
  { data_type => "CHAR", default_value => "", is_nullable => 0, size => 9 },
  "fund_id",
  { data_type => "CHAR", default_value => "", is_nullable => 0, size => 5 },
  "sub_fund_id",
  { data_type => "CHAR", default_value => "", is_nullable => 0, size => 5 },
  "fund_value",
  {
    data_type => "DECIMAL",
    default_value => undef,
    is_nullable => 1,
    size => 16,
  },
  "fund_pct",
  {
    data_type => "DECIMAL",
    default_value => undef,
    is_nullable => 1,
    size => 10,
  },
  "fund_units",
  {
    data_type => "DECIMAL",
    default_value => undef,
    is_nullable => 1,
    size => 18,
  },
  "fund_guaranteed_interest_rate",
  {
    data_type => "DECIMAL",
    default_value => undef,
    is_nullable => 1,
    size => 10,
  },
  "fund_name",
  {
    data_type => "VARCHAR",
    default_value => undef,
    is_nullable => 1,
    size => 40,
  },
  "fund_type",
  { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 3 },
  "fund_cusip",
  { data_type => "CHAR", default_value => undef, is_nullable => 1, size => 9 },
  "fund_rest_i",
  { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 1 },
);
__PACKAGE__->set_primary_key("nscc_num", "contract_num", "cusip", "fund_id", "sub_fund_id");

__PACKAGE__->belongs_to(contract => 'Finance::NSCC::Insurance::Schema::Contract',
                        {
                         'foreign.nscc_num'     => 'self.nscc_num',
                         'foreign.contract_num' => 'self.contract_num',
                        }
                       );

__PACKAGE__->has_many(guarantees => 'Finance::NSCC::Insurance::Schema::UnderlyingAssetGuarantee',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                       'foreign.cusip'        => 'self.cusip',
                       'foreign.fund_id'      => 'self.fund_id',
                       'foreign.sub_fund_id'  => 'self.sub_find_id',
                      }
                     );
1;
